/*****************************************************************
Copyright (c) 2011 - 2016 Qualcomm Technologies International, Ltd.

PROJECT
    source

FILE NAME
    source_usb.h

DESCRIPTION
    USB functionality.

*/


#ifndef _SOURCE_USB_H_
#define _SOURCE_USB_H_


/* profile/library headers */
#include <avrcp.h>
/* VM headers */
#include <sink.h>
#include <message.h>
#include <library.h>

/* HID Descriptor */
#define USB_HID_DESCRIPTOR_LENGTH 9
#define USB_B_DESCRIPTOR_TYPE_HID 0x21
#define USB_B_DESCRIPTOR_TYPE_HID_REPORT 0x22
#define USB_HID_CONSUMER_TRANSPORT_REPORT_DESCRIPTOR_LENGTH 98

/* Audio Descriptor Unit/Terminal IDs */
#define USB_AUDIO_SPEAKER_IT            0x01
#define USB_AUDIO_SPEAKER_FU            0x02
#define USB_AUDIO_SPEAKER_OT            0x03
#define USB_AUDIO_MIC_IT                0x04
#define USB_AUDIO_MIC_FU                0x05
#define USB_AUDIO_MIC_OT                0x06

/*! Audio Device Class Request Types */
#define SET       0x00
#define GET       0x80

/*! Audio Device Class Request Codes */
#define REQ_CUR             0x01
#define REQ_MIN             0x02
#define REQ_MAX             0x03
#define REQ_RES             0x04
#define REQ_MEM             0x05

#define SET_CUR (SET | REQ_CUR)
#define SET_MIN (SET | REQ_MIN)
#define SET_MAX (SET | REQ_MAX)
#define SET_RES (SET | REQ_RES)
#define SET_MEM (SET | REQ_MEM)
#define GET_CUR (GET | REQ_CUR)
#define GET_MIN (GET | REQ_MIN)
#define GET_MAX (GET | REQ_MAX)
#define GET_RES (GET | REQ_RES)
#define GET_MEM (GET | REQ_MEM)

/*! Interface Sub-Types */
#define HEADER          0x01
#define INPUT_TERMINAL  0x02
#define OUTPUT_TERMINAL 0x03
#define MIXER_UNIT      0x04
#define SELECTOR_UNIT   0x05
#define FEATURE_UNIT    0x06
#define PROCESSING_UNIT 0x07
#define EXTENSION_UNIT  0x08

/*! Endpoint Control Selectors */
#define SAMPLING_FREQ_CONTROL (0x01)

/*! Feature Unit Control Selectors */
#define FU_CONTROL_UNDEFINED        0x00
#define MUTE_CONTROL                0x01
#define VOLUME_CONTROL              0x02
#define BASS_CONTROL                0x03
#define MID_CONTROL                 0x04
#define TREBLE_CONTROL              0x05
#define GRAPHIC_EQUALIZER_CONTROL   0x06
#define AUTOMATIC_GAIN_CONTROL      0x07
#define DELAY_CONTROL               0x08
#define BASS_BOOST_CONTROL          0x09
#define LOUDNESS_CONTROL            0x0A

/*! Helpers */
#define REQ_CS(req)         (req.wValue >> 8)
#define REQ_CN(req)         (req.wValue & 0xFF)
#define REQ_CODE(req)       (req.bRequest & 0x07)
#define REQ_UNIT(req)       (req.wIndex >> 8)
#define REQ_INTERFACE(req)  (req.wIndex & 0xFF)
#define REQ_IS_GET(req)     (req.bRequest & GET)

/* USB Audio Sample Rates and Packet Sizes */
/* The Mic configuration is the audio sent to USB. The Speaker configuration is the audio received from USB. */
#define USB_AUDIO_PACKET_RATE_MS        1000
#define USB_AUDIO_SAMPLE_SIZE           2
#define USB_AUDIO_CHANNELS_MIC          1
#define USB_AUDIO_CHANNEL_CONFIG_MIC    1


#define USB_AUDIO_STEREO_SPEAKER
#define USB_AUDIO_SAMPLE_RATE_MIC           (uint32)16000
#define USB_AUDIO_SAMPLE_RATE_SPEAKER       (uint32)48000
#define USB_AUDIO_CHANNELS_SPEAKER          2
#define USB_AUDIO_CHANNEL_CONFIG_SPEAKER    3


#define USB_AUDIO_MAX_PACKET_SIZE_MIC       (USB_AUDIO_SAMPLE_RATE_MIC / (USB_AUDIO_PACKET_RATE_MS / USB_AUDIO_SAMPLE_SIZE) * USB_AUDIO_CHANNELS_MIC)
#define USB_AUDIO_MAX_PACKET_SIZE_SPEAKER   (USB_AUDIO_SAMPLE_RATE_SPEAKER / (USB_AUDIO_PACKET_RATE_MS / USB_AUDIO_SAMPLE_SIZE) * USB_AUDIO_CHANNELS_SPEAKER)


/* HID Report Types */
#define USB_CONSUMER_REPORT_ID                  0x07
#define USB_DATA_LINK_REPORT_ID                 0x08
#define USB_TELEPHONY_REPORT_ID                 0x09
#define USB_CONSUMER_REPORT_SIZE                2
#define USB_DATA_LINK_REPORT_SIZE               63
#define USB_TELEPHONY_REPORT_SIZE               2

#define USB_HID_TELEPHONY_REPORT_OFF_HOOK_MASK  1 << 0
#define USB_HID_TELEPHONY_REPORT_MUTE_MASK      1 << 1
#define USB_HID_TELEPHONY_REPORT_RING_MASK      1 << 2
#define USB_HID_TELEPHONY_REPORT_HOLD_MASK      1 << 3

#define USB_HID_TELEPHONY_HOOK_SWITCH           1 << 0
#define USB_HID_TELEPHONY_PHONE_MUTE            1 << 1
#define USB_HID_TELEPHONY_FLASH                 1 << 2
#define USB_HID_TELEPHONY_REDIAL                1 << 3



/* Delay (in ms) before starting audio when active interface message received */
#define USB_AUDIO_ACTIVE_DELAY          300
/* Delay (in ms) before acting on active Mic */
#define MIC_AUDIO_ACTIVE_DELAY          500
/* Delay (in ms) before acting on inactive Mic */
#define MIC_AUDIO_INACTIVE_DELAY        500


typedef enum
{
    USB_STATE_DETACHED,
    USB_STATE_ATTACHED,
    USB_STATE_ENUMERATED,
    USB_STATE_SUSPENDED
} USB_STATE_T;


/* HID modes */
typedef enum
{
    USB_HID_MODE_CONSUMER,
    USB_HID_MODE_HOST
} USB_HID_MODE_T;

typedef enum
{
    USB_HID_VOLUME_SYNCED = 0,
    USB_HID_VOLUME_GOING_UP,
    USB_HID_VOLUME_GOING_DOWN
}USB_HID_VOL_SYNC_STATE_T;

/** USB interface types */
typedef enum
{
    usb_interface_audio_control,
    usb_interface_audio_streaming_mic,
    usb_interface_audio_streaming_speaker,
    usb_interface_hid_consumer_transport,
    usb_interface_hid_keyboard,
    usb_interface_mass_storage,
    usb_interface_hid_datalink,
    usb_interface_max /* must leave as final entry in enum */
} usb_interface_type;

#define MAX_USB_INTERFACES usb_interface_max


/*!
    Structure to pass when calling UsbDeviceClassGetValue to obtain USB_DEVICE_CLASS_GET_VALUE_AUDIO_LEVELS
*/
typedef struct
{
    /*! Left and right gain settings */
    int16     out_l_vol;
    int16     out_r_vol;
    /*! Input Gain setting */
    int16     in_vol;
    /*! Speaker/mic mute settings (TRUE/FALSE) */
    uint16    out_mute;
    uint16    in_mute;
    /*! Flag to indicate if the audio levels are user supplied */
    bool      user_audio_levels;
} usb_device_class_audio_levels;

/*!
    Structure to hold interface descriptor. Descriptors must be constant, or if allocated may not be freed.
*/
typedef struct
{
    const uint8*        descriptor;
    uint16              size_descriptor;
    const EndPointInfo* end_point_info;
} usb_device_class_descriptor;


/*!
    Structure to pass as params when calling UsbDeviceClassConfigure to set USB_DEVICE_CLASS_CONFIG_AUDIO_INTERFACE_DESCRIPTORS.
    Interface descriptors must be set prior to calling UsbDeviceClassEnumerate if the application wishes to use custom descriptors,
    otherwise defaults will be used. This structure must contain all descriptors required for the enumerated audio device classes.
    Terminal and unit ID's must match those used by the library, i.e. Microphone(4) -> Feature Unit(5) -> USB Output Terminal(6)
                                                                      USB Input Terminal(1) -> Feature Unit(2) -> Speaker(3)
*/
typedef struct
{
    usb_device_class_descriptor    control;
    usb_device_class_descriptor    streaming_mic;
    usb_device_class_descriptor    streaming_speaker;
} usb_device_class_audio_config;


/*!
    Structure to pass as params when calling UsbDeviceClassConfigure to set USB_DEVICE_CLASS_CONFIG_HID_CONSUMER_TRANSPORT_DESCRIPTORS.
    Interface descriptors must be set prior to calling UsbDeviceClassEnumerate if the application wishes to use custom descriptors,
    otherwise defaults will be used.

*/
typedef struct
{
    usb_device_class_descriptor    interface;
    usb_device_class_descriptor    report;
} usb_device_class_hid_consumer_transport_config;

/* USB data structure */
typedef struct
{
    USB_HID_MODE_T hid_mode;
    unsigned ffwd_press:1;
    unsigned rew_press:1;

    TaskData        usbTask;
    uint8           hostOperatingSystem;              /**< Operating system running on host */
    int16           hostMicVolume;
    uint16          hostMicMute;
    uint16          hostMicSampleRate;
    int16           hostSpeakerVolume;
    bool            notMacOs;
    bool            pcVolumeWait;
    uint16          hostSpeakerMute;
    uint16          hostSpeakerSampleRate;
    uint16          speakerAltsetting;
    uint16          micAltsetting;      
    uint8           headsetSpeakerVolume;
    USB_HID_VOL_SYNC_STATE_T volumeSyncState;
    uint16          outputTelephonyReport;
    uint16          inputTelephonyReport;
    UsbInterface    usb_interface[MAX_USB_INTERFACES];
    bool            hostAppIsConnected;
    USB_STATE_T     state;
} USB_DATA_T;


/* Possible Host Commands sent to Device */
typedef enum
{
    USB_HOST_COMMAND_HOST_CONNECTION = 0,
    USB_HOST_COMMAND_INQUIRY,
    USB_HOST_COMMAND_CONNECT_REMOTE_DEVICE,
    USB_HOST_COMMAND_DISCONNECT_REMOTE_DEVICE,
    USB_HOST_COMMAND_CONNECTED_DEVICE,
    USB_HOST_COMMAND_GET_TDL,
    USB_HOST_COMMAND_GET_SECURITY,
    USB_HOST_COMMAND_SET_SECURITY,
    USB_HOST_COMMAND_ENTER_TEST_MODE,
    USB_HOST_COMMAND_GET_SERIAL_NUMBER,
    USB_HOST_COMMAND_GET_LAST_CONNECT_DEVICE,
    USB_HOST_COMMAND_GET_LINK_KEY,
    USB_HOST_COMMAND_GET_LOCAL_ADDRESS,
    USB_HOST_COMMAND_AUDIO_CODEC,
    USB_HOST_COMMAND_WRITE_NEW_PAIRED_DEVICE,
	USB_HOST_COMMAND_LOCK_REMOVE_DEVICE,
	USB_HOST_COMMAND_ENTER_RF_DUT_MODE,
	USB_HOST_COMMAND_FW_UPGRADE,
	USB_HOST_COMMAND_DEVICE_SETTING
} USB_HOST_COMMAND_T;


typedef enum
{
    USB_DEVICE_EVENT_INQUIRY_RESULT,
    USB_DEVICE_EVENT_REMOTE_DEVICE_CONNECTED,
    USB_DEVICE_EVENT_REMOTE_DEVICE_DISCONNECTED,
    USB_DEVICE_EVENT_LAST_CONNECTED_DEVICE,
    USB_DEVICE_EVENT_SERIAL_NUMBER,
    USB_DEVICE_EVENT_LINK_KEY_OF_LAST_CONNECTED_DEVICE,
    USB_DEVICE_EVENT_LOCAL_ADDRESS,
    USB_DEVICE_EVENT_SECURITY
}USB_DEVICE_EVENT_T;

/* Data sent with USB_HOST_COMMAND_HOST_CONNECTION command Host->Device */
typedef enum
{
    USB_HOST_DATA_HOST_CONNECTION_DISCONNECTED,
    USB_HOST_DATA_HOST_CONNECTION_CONNECTED
} USB_HOST_DATA_HOST_CONNECTION_T;

/* Data sent with USB_HOST_COMMAND_STATE command Host->Device */
typedef enum
{
    USB_HOST_DATA_STATE_GET_STATE,
    USB_HOST_DATA_STATE_ENTER_DFU_MODE,
    USB_HOST_DATA_STATE_ENTER_DUT_MODE,
    USB_HOST_DATA_STATE_INQUIRY,
    USB_HOST_DATA_STATE_INQUIRY_SCAN,
    USB_HOST_DATA_STATE_PAGE,
    USB_HOST_DATA_STATE_PAGE_SCAN
} USB_HOST_DATA_STATE_T;

/* Data sent with USB_HOST_COMMAND_AG_CALL_STATE command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_CALL_STATE_NONE,
    USB_HOST_DATA_AG_CALL_STATE_INCOMING,
    USB_HOST_DATA_AG_CALL_STATE_OUTGOING,
    USB_HOST_DATA_AG_CALL_STATE_ACTIVE,
    USB_HOST_DATA_AG_CALL_STATE_CALL_WAITING_ACTIVE_CALL,
    USB_HOST_DATA_AG_CALL_STATE_CALL_HELD_ACTIVE_CALL,
    USB_HOST_DATA_AG_CALL_STATE_CALL_HELD
} USB_HOST_DATA_AG_CALL_STATE_T;

/* Data sent with USB_HOST_COMMAND_SIGNAL_STRENGTH command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_SIGNAL_STRENGTH_VALUE
} USB_HOST_DATA_AG_SIGNAL_STRENGTH_T;

/* Data sent with USB_HOST_COMMAND_BATTERY_LEVEL command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_BATTERY_LEVEL_VALUE
} USB_HOST_DATA_AG_BATTERY_LEVEL_T;

/* Data sent with USB_HOST_COMMAND_AG_LINK_MODE command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_LINK_GET_MODE
} USB_HOST_DATA_AG_LINK_MODE_T;

/* Data sent with USB_HOST_COMMAND_AG_AUDIO command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_AUDIO_GET_STATE,
    USB_HOST_DATA_AG_AUDIO_TRANSFER
} USB_HOST_DATA_AG_AUDIO_T;

/* Data sent with USB_HOST_COMMAND_AG_NETWORK command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_NETWORK_OPERATOR,
    USB_HOST_DATA_AG_NETWORK_AVAILABILITY,
    USB_HOST_DATA_AG_NETWORK_ROAM
} USB_HOST_DATA_AG_NETWORK_T;

/* Data sent with USB_HOST_COMMAND_AG_HF_INDICATOR command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_HF_INDICATOR_NONE,
    USB_HOST_DATA_AG_HF_INDICATOR_ENHANCED_SAFETY,
    USB_HOST_DATA_AG_HF_INDICATOR_BATTERY_LEVEL
} USB_HOST_DATA_AG_HF_INDICATOR_T;

/* Data sent with USB_HOST_COMMAND_AG_ERROR command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_ERROR_INVALID_MEMORY_LOCATION,
    USB_HOST_DATA_AG_ERROR_INVALID_LAST_NUMBER_DIAL
} USB_HOST_DATA_AG_ERROR_T;

/* Data sent with USB_HOST_COMMAND_AG_OK command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_OK_VALID_MEMORY_LOCATION,
    USB_HOST_DATA_AG_OK_VALID_LAST_NUMBER_DIAL,
    USB_HOST_DATA_AG_OK_SENT_ALL_CURRENT_CALLS
} USB_HOST_DATA_AG_OK_T;

/* Data sent with USB_HOST_COMMAND_AG_CURRENT_CALL command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_CURRENT_CALL_DETAILS
} USB_HOST_DATA_AG_CURRENT_CALL_T;

/* Data sent with USB_HOST_COMMAND_AG_VOICE_RECOGNITION command Host->Device */
typedef enum
{
    USB_HOST_DATA_AG_VOICE_RECOGNITION_DISABLE,
    USB_HOST_DATA_AG_VOICE_RECOGNITION_ENABLE
} USB_HOST_DATA_AG_VOICE_RECOGNITION_T;

/* Possible Device Commands sent to Host */
typedef enum
{
    USB_DEVICE_COMMAND_STATE,
    USB_DEVICE_COMMAND_AG_CALL,
    USB_DEVICE_COMMAND_AG_AUDIO_STATE,
    USB_DEVICE_COMMAND_AG_VOICE_RECOGNITION,
    USB_DEVICE_COMMAND_AG_LINK_MODE
} USB_DEVICE_COMMAND_T;

/* Data sent with USB_DEVICE_COMMAND_STATE command Device->Host */
typedef enum
{
    USB_DEVICE_DATA_STATE_INQUIRY,
    USB_DEVICE_DATA_STATE_INQUIRY_SCAN,
    USB_DEVICE_DATA_STATE_PAGE,
    USB_DEVICE_DATA_STATE_PAGE_SCAN,
    USB_DEVICE_DATA_STATE_CONNECTED,
    USB_DEVICE_DATA_STATE_UNKNOWN
} USB_DEVICE_DATA_STATE_T;

/* Data sent with USB_DEVICE_COMMAND_AG_CALL command Device->Host */
typedef enum
{
    USB_DEVICE_COMMAND_AG_CALL_ACCEPT,
    USB_DEVICE_COMMAND_AG_CALL_REJECT,
    USB_DEVICE_COMMAND_AG_CALL_NUMBER_SUPPLIED,
    USB_DEVICE_COMMAND_AG_CALL_MEMORY,
    USB_DEVICE_COMMAND_AG_CALL_LAST_NUMBER,
    USB_DEVICE_COMMAND_AG_CALL_GET_CURRENT_CALLS
} USB_DEVICE_DATA_AG_CALL_T;

/* Data sent with USB_DEVICE_COMMAND_AG_AUDIO_STATE command Device->Host */
typedef enum
{
    USB_DEVICE_DATA_AG_AUDIO_STATE_NO_SLC_CONNECTION,
    USB_DEVICE_DATA_AG_AUDIO_STATE_AUDIO_DISCONNECTED,
    USB_DEVICE_DATA_AG_AUDIO_STATE_AUDIO_CONNECTED
} USB_DEVICE_DATA_AG_AUDIO_STATE_T;

/* Data sent with USB_DEVICE_COMMAND_AG_VOICE_RECOGNITION command Device->Host */
typedef enum
{
    USB_DEVICE_DATA_AG_VOICE_RECOGNITION_DISABLE,
    USB_DEVICE_DATA_AG_VOICE_RECOGNITION_ENABLE
} USB_DEVICE_DATA_AG_VOICE_RECOGNITION_T;

/* Data sent with USB_DEVICE_COMMAND_AG_LINK_MODE command Device->Host */
typedef enum
{
    USB_DEVICE_DATA_AG_LINK_MODE_NO_SLC_CONNECTION,
    USB_DEVICE_DATA_AG_LINK_MODE_UNSECURE,
    USB_DEVICE_DATA_AG_LINK_MODE_SECURE
} USB_DEVICE_DATA_AG_LINK_MODE_T;


typedef enum
{
    USB_HID_TELEPHONY_CMD_HOOK_SWITCH,
    USB_HID_TELEPHONY_CMD_PHONE_MUTE,
    USB_HID_TELEPHONY_CMD_FLASH,
    USB_HID_TELEPHONY_CMD_REDIAL,
    USB_HID_TELEPHONY_CMD_NONE
} USB_HID_TELEPHONY_CMD_T;


typedef enum
{
    USB_CLASS_MSG_VOLUME_GOING_UP = USB_DEVICE_CLASS_MSG_BASE,
    USB_CLASS_MSG_VOLUME_GOING_DOWN,
    /* Library message limit */
    USB_CLASS_MSG_TOP
} usb_class_message;


typedef enum
{
    USB_HID_MEDIA_VOL_UP,
    USB_HID_MEDIA_VOL_DOWN,
    USB_HID_MEDIA_PAUSE,
    USB_HID_MEDIA_STOP,
    USB_HID_MEDIA_PLAY,
    USB_HID_MEDIA_NEXT_TRACK,
    USB_HID_MEDIA_PREVIOUS_TRACK,
    USB_HID_MEDIA_PLAY_PAUSE
} USB_HID_MEDIA_CMD_T;

/***************************************************************************
Function definitions
****************************************************************************
*/


/****************************************************************************
NAME
    usb_time_critical_init

DESCRIPTION
    Enumerate as a USB device before the main application starts up.

*/
void usb_time_critical_init(void);


/****************************************************************************
NAME
    usb_get_speaker_source

DESCRIPTION
    Finds the speaker Source.

RETURNS
    The speaker Source.

*/
Source usb_get_speaker_source(void);


/****************************************************************************
NAME
    usb_get_mic_sink

DESCRIPTION
    Finds the mic Sink.

RETURNS
    The mic Sink.

*/
Sink usb_get_mic_sink(void);


/****************************************************************************
NAME
    usb_get_hid_mode

DESCRIPTION
    Finds the current HID mode.

RETURNS
    The current HID mode.

*/
USB_HID_MODE_T usb_get_hid_mode(void);


/****************************************************************************
NAME
    usb_set_hid_mode

DESCRIPTION
    Sets the current HID mode.

*/
void usb_set_hid_mode(USB_HID_MODE_T mode);





/****************************************************************************
NAME
    usb_get_speaker_sample_rate

DESCRIPTION
    Gets the configured USB sample rate for the speaker.
*/
uint32 usb_get_speaker_sample_rate(void);


/****************************************************************************
NAME
    usb_send_telephony_cmd - Sends a HID command to operate a call
*/

bool usb_send_telephony_cmd(USB_HID_TELEPHONY_CMD_T cmd, bool value);


/****************************************************************************
NAME
    usbSetDeviceSpeakerVolume - tell headset volume to usb module
*/

void usbSetDeviceSpeakerVolume(uint8 volume);


/****************************************************************************
NAME
    usbGetDeviceSpeakerVolume - get headset volume
*/

uint8 usbGetHeadsetSpeakerVolume(void);


/****************************************************************************
NAME
    usb_send_media_hid_command - Get USB media command to host
*/
void usbHidSendMediaCommand(USB_HID_MEDIA_CMD_T mediaControl);


/****************************************************************************
NAME
    usb_send_media_hid_command - Send USB media command to host
*/
void usb_send_media_hid_command(avc_operation_id op_id, bool state);


/****************************************************************************
NAME
    usbSendVendorCommandInquiryResult - Send inquiry result to host
*/
bool usbSendVendorCommandInquiryResult(bdaddr addr, int16 rssi, uint8 *deviceName, uint8 deviceNameLen);


/****************************************************************************
NAME
    usbSendVendorCommandSettings - Send settings to host
*/
bool usbSendVendorCommandSettings(uint8 *settings, uint8 size);


/****************************************************************************
NAME
    usbSendVendorCommandConnectedDeviceInfo - Send connected device information to host
*/
bool usbSendVendorCommandConnectedDeviceInfo(bdaddr addr, uint8 *name, uint8 nameSize);


/****************************************************************************
NAME
    usbSendVendorCommandLastConnectedDeviceInfo - Send last connected device information to host
*/
bool usbSendVendorCommandLastConnectedDeviceInfo(bdaddr addr, uint8 *name, uint8 nameSize, bool connected);


/****************************************************************************
NAME
    usbSendVendorCommandRemoteDeviceDisconnected - Send remote device disconnect event to host
*/
bool usbSendVendorCommandRemoteDeviceDisconnected(void);


/****************************************************************************
NAME
    usbSendVendorCommandSerialNumber - Send serial number to host
*/
bool usbSendVendorCommandSerialNumber(uint16 *sn, uint16 sn_size);


/****************************************************************************
NAME
    usbSendVendorCommandLinkKey - Send link key to host
*/
void usbSendVendorCommandLinkKey(bdaddr bd_addr, uint16 *link_key, uint16 size_link_key);


/****************************************************************************
NAME
    usbSendVendorCommandLocalAddr - Send local bluetooth address to host
*/

void usbSendVendorCommandLocalAddr(bdaddr bd_addr);

bool usb_stream_out_is_active(void);

bool usb_stream_in_is_active(void);

void usb_detach(void);

void usb_attach(void);

bool usbHidSendInputReport(uint16 report_id, uint16 size_report, uint8 *report);

bool usbHidSendChunkData(uint8 *report, uint16 size_report);

USB_STATE_T usb_get_state(void);

uint32 usbGetHostSpeakerRate(void);

void sourceUsbSendAudioCodec(uint8 seid);

bool sourceUsbCanVolUp(void);

bool sourceUsbCanVolDown(void);

bool usbtHostSpeakerIsMute(void);
#endif /* _SOURCE_USB_H_ */
